package com.leyou.common.exception;

import com.leyou.common.enums.ExceptionEnum;
import lombok.Getter;

//自定义异常，用来处理  RuntimeException

@Getter
public class LyException extends RuntimeException {
    //响应状态码
    private int status;

    //注入枚举对象
    public LyException(ExceptionEnum em){
        //将枚举对象的消息返回给 RuntimeException
        super(em.getMessage());
        //取出枚举常量的状态表
        this.status = em.getStatus();
    }

    public LyException(ExceptionEnum em,Throwable cause){
        //将枚举对象的消息返回给 RuntimeException
        super(em.getMessage(),cause);
        //取出枚举常量的状态表
        this.status = em.getStatus();
    }

    public LyException(String em,Integer code){
        //将枚举对象的消息返回给 RuntimeException
        super(em);
        //取出枚举常量的状态表
        this.status = code;
    }
}
